package com.gy.spring.mvc.common.interceptor;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;

import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * TODO Swagger2配置类
 * Swagger2注解说明: https://blog.csdn.net/xiaojin21cen/article/details/78654652
 *
 * @author geYang
 * @date 2018-04-16
 */
@Configuration
@EnableWebMvc
@EnableSwagger2
public class SwaggerConfig {

    @Bean
    public Docket customDocket() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .select().apis(RequestHandlerSelectors.basePackage("com.gy.spring.mvc.controller"))
                .paths(PathSelectors.regex("/user/.*"))
                .build();

    }

    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("API接口文档")
                .description("API接口文档描述")
                .version("0.0.1")
                .contact(new Contact("geYang", "https://my.oschina.net/u/3681868/home", "572119197@qq.com"))
//        		.termsOfServiceUrl("URL的服务条款")
//        		.license(null)
//        		.licenseUrl(null)
                .build();
    }

}
